package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.ApprovalStageQuery;
import com.example.orderflow.entity.po.ApprovalStage;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.ApprovalStageService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("approvalStageController")
@RequestMapping("/approvalStage")
public class ApprovalStageController extends ABaseController {

	@Resource
	private ApprovalStageService approvalStageService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ApprovalStageQuery query){
		return getSuccessResponseVO(approvalStageService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(ApprovalStage bean) {
		approvalStageService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<ApprovalStage> listBean) {
		approvalStageService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<ApprovalStage> listBean) {
		approvalStageService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据ApprovalId查询对象
	 */
	@RequestMapping("/getApprovalStageByApprovalId")
	public ResponseVO getApprovalStageByApprovalId(Integer approvalId) {
		return getSuccessResponseVO(approvalStageService.getApprovalStageByApprovalId(approvalId));
	}

	/**
	 * 根据ApprovalId修改对象
	 */
	@RequestMapping("/updateApprovalStageByApprovalId")
	public ResponseVO updateApprovalStageByApprovalId(ApprovalStage bean,Integer approvalId) {
		approvalStageService.updateApprovalStageByApprovalId(bean,approvalId);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据ApprovalId删除
	 */
	@RequestMapping("/deleteApprovalStageByApprovalId")
	public ResponseVO deleteApprovalStageByApprovalId(Integer approvalId) {
		approvalStageService.deleteApprovalStageByApprovalId(approvalId);
		return getSuccessResponseVO(null);
	}
}